home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / ixemul / sdk / man / cat2 / shmctl.0 < prev    next >
Encoding:
Text File  |  1998-06-15  |  5.0 KB  |  104 lines

  1.  
  2. SHMCTL(2)                  UNIX Programmer's Manual                  SHMCTL(2)
  3.  
  4. NNAAMMEE
  5.      sshhmmccttll - shared memory control operations
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
  9.      ##iinncclluuddee <<ssyyss//iippcc..hh>>
  10.      ##iinncclluuddee <<ssyyss//mmssgg..hh>>
  11.  
  12.      _i_n_t
  13.      sshhmmccttll(_i_n_t _s_h_m_i_d, _i_n_t _c_m_d, _s_t_r_u_c_t _s_h_m_i_d___d_s _*_b_u_f)
  14.  
  15. DDEESSCCRRIIPPTTIIOONN
  16.      The sshhmmccttll() system call performs some control operations on the shared
  17.      memory area specified by _s_h_m_i_d.
  18.  
  19.      Each shared memory segment has a data structure associated with it, parts
  20.      of which may be altered by sshhmmccttll() and parts of which determine the ac-
  21.      tions of sshhmmccttll().
  22.  
  23.      This structure is defined as follows in <_s_y_s_/_s_h_m_._h>:
  24.  
  25.      struct shmid_ds {
  26.          struct ipc_perm shm_perm;     /* operation permissions */
  27.          int             shm_segsz;    /* size of segment in bytes */
  28.          pid_t           shm_lpid;     /* pid of last shm op */
  29.          pid_t           shm_cpid;     /* pid of creator */
  30.          short           shm_nattch;   /* # of current attaches */
  31.          time_t          shm_atime;    /* last shmat() time*/
  32.          time_t          shm_dtime;    /* last shmdt() time */
  33.          time_t          shm_ctime;    /* last change by shmctl() */
  34.          void           *shm_internal; /* sysv stupidity */
  35.      };
  36.      The ipc_perm  structure used inside the shmid_ds  structure is defined in
  37.      <_s_y_s_/_i_p_c_._h> and looks like this:
  38.  
  39.      struct ipc_perm {
  40.          ushort cuid; /* creator user id */
  41.          ushort cgid; /* creator group id */
  42.          ushort uid;  /* user id */
  43.          ushort gid;  /* group id */
  44.          ushort mode; /* r/w permission (see chmod(2)) */
  45.          ushort seq;  /* sequence # (to generate unique msg/sem/shm id) */
  46.          key_t key;   /* user specified msg/sem/shm key */
  47.      };
  48.  
  49.      The operation to be performed by sshhmmccttll() is specified in _c_m_d and is one
  50.      of:
  51.  
  52.      IPC_STAT   Gather information about the shared memory segment and place
  53.                 it in the structure pointed to by _b_u_f.
  54.  
  55.      IPC_SET    Set the value of the _s_h_m___p_e_r_m_._u_i_d, _s_h_m___p_e_r_m_._g_i_d and
  56.                 _s_h_m___p_e_r_m_._m_o_d_e fields in the structure associated with _s_h_m_i_d.
  57.                 The values are taken from the corresponding fields in the
  58.                 structure pointed to by _b_u_f. This operation can only be exe-
  59.                 cuted by the super-user, or a process that has an effective
  60.                 user id equal to either _s_h_m___p_e_r_m_._c_u_i_d or _s_h_m___p_e_r_m_._u_i_d in the
  61.                 data structure associated with the shared memory segment.
  62.  
  63.  
  64.      IPC_RMID   Remove the shared memory segment specified by _s_h_m_i_d and de-
  65.                 stroy the data associated with it. Only the super-user or a
  66.                 process with an effective uid equal to the _s_h_m___p_e_r_m_._c_u_i_d or
  67.                 _s_h_m___p_e_r_m_._u_i_d values in the data structure associated with the
  68.                 queue can do this.
  69.  
  70.      The read and write permissions on a shared memory identifier are deter-
  71.      mined by the _s_h_m___p_e_r_m_._m_o_d_e field in the same way as is done with files
  72.      (see chmod(2)),  but the effective uid can match either the _s_h_m___p_e_r_m_._c_u_i_d
  73.      field or the _s_h_m___p_e_r_m_._u_i_d field, and the effective gid can match either
  74.      _s_h_m___p_e_r_m_._c_g_i_d or _s_h_m___p_e_r_m_._g_i_d.
  75.  
  76. RREETTUURRNN VVAALLUUEESS
  77.      Upon successful completion, a value of 0 is returned. Otherwise, -1 is
  78.      returned and the global variable _e_r_r_n_o is set to indicate the error.
  79.  
  80. EERRRROORRSS
  81.      sshhmmccttll() will fail if:
  82.  
  83.      [EPERM]       _c_m_d is equal to IPC_SET or IPC_RMID and the caller is not
  84.                    the super-user, nor does the effective uid match either the
  85.                    _s_h_m___p_e_r_m_._u_i_d or _s_h_m___p_e_r_m_._c_u_i_d fields of the data structure
  86.                    associated with the shared memory segment.
  87.  
  88.                    An attempt is made to increase the value of _s_h_m___q_b_y_t_e_s
  89.                    through IPC_SET but the caller is not the super-user.
  90.  
  91.      [EACCESS]     The command is IPC_STAT and the caller has no read permis-
  92.                    sion for this shared memory segment.
  93.  
  94.      [EINVAL]      _s_h_m_i_d is not a valid shared memory segment identifier.
  95.  
  96.                    _c_m_d is not a valid command.
  97.  
  98.      [EFAULT]      _b_u_f specifies an invalid address.
  99.  
  100. SSEEEE AALLSSOO
  101.      shmat(2),  shmdt(2),  shmget(2)
  102.  
  103.  NetBSD                         August 17, 1995                              2
  104.